<template>
    <el-row>
        <el-col :span="24">
            <el-table border stripe :data="tableData" style="width: 100%">
                <el-table-column prop="symbol" label="合约"  min-width="100" />
                <el-table-column prop="direction" label="方向"  min-width="100">
                    <template slot-scope="scope">
                        <div v-if="scope.row.direction == 1">多</div>
                        <div v-if="scope.row.direction == 2">空</div>
                    </template>
                </el-table-column>
                <el-table-column prop="volume" label="手数"  min-width="100" />
                <el-table-column prop="price" label="买价"  min-width="100" />
                <el-table-column prop="entryDate" label="建仓时间"  min-width="100">
                </el-table-column>
                <!-- 币种 1 人民币 ， 2 港币 ， 3 美元 ， 4 概率豆 -->
                <el-table-column prop="currencyEnum" label="货币" min-width="100">
                    <template slot-scope="scope">
                        <!-- <div v-if="scope.row.currencyEnum == 1">人民币</div>
                        <div v-if="scope.row.currencyEnum == 2">港币</div>
                        <div v-if="scope.row.currencyEnum == 3">美元</div>
                        <div v-if="scope.row.currencyEnum == 4">概率豆</div> -->
                        <div :class="scope.row.currencyEnum">概率豆</div>
                    </template>
                </el-table-column>
            </el-table>

            <!-- 分页 -->
            <!-- <div class="block m-bottom-15">
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page="currentPage" :page-sizes="[10, 20, 35, 50]" :page-size="limit"
                    layout="total, sizes, prev, pager, next" :total="total">
                </el-pagination>
            </div> -->
        </el-col>
    </el-row>
</template>

<script>
import { getTradeHistory ,getPosition  } from '@/api/trainerAnalyze'

import { currencyGetOption } from "@/api/transaction";
export default {
    data() {
        return {
            tableData: [
                // {
                //     pact: '恒指2308',
                //     direction: '买',
                //     handCount: 1,
                //     buyingPrice: 18100,
                //     sellingPrice: 17936,
                //     profitAndLoss: -8200,
                //     openingTime: '2023-08-18 11:22:43',
                //     closingTime: '2023-08-18 11:22:43',
                //     currency: 'HKD/港币'
                // }
            ],
            total: 0,
            limit: 10,
            page: 1,
            currentPage: 1,

            paramsObj:{}
        }
    },
    mounted() {
        let obj = {
            uid: this.$route.query.uid,
            traderAccountId: this.$route.query.traderAccountId,
            limit: this.limit,
            page: this.page
        }
        this.paramsObj=obj;

        this.getdata()

    },
    methods: {
        getdata() {
            let that = this;
            let obj=that.paramsObj
            obj.limit=that.limit;
            obj.page=that.currentPage;

            // getTradeHistory(obj).then(res => {
            //     console.log('持仓历史', res)
            //     that.tableData = res.list;
            //     that.limit=res.limit;
            //     that.total=res.total;
            //     that.currentPage=res.page;
            // }).catch(res => {
            //     console.log(res)
            // })

            getPosition(obj).then(res => {
                console.log('持仓数据：', res)
                that.tableData = res;
                // that.limit=res.limit;
                // that.total=res.total;
                // that.currentPage=res.page;
            }).catch(res => {
                console.log(res)
            })
        },

        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            let that = this;
            that.limit = val;
            this.getdata();

        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            let that = this;
            that.currentPage = val;
            this.getdata()

        },
    }
}
</script>

<style lang="scss" scoped></style>
